// 1.引入基础模块
import {
    defineStore
} from 'pinia'

import changeAutoTheme from "../utils/theme.js"

// 2.实例化仓库  每个仓库文件都是一个模块
export default defineStore('storeId', {
    // 2.1state
    state() {
        return {
            themeName: "dark", //主题名称
            autoTheme: changeAutoTheme("dark")
        }
    },
    // 2.2getters
    getters: {
        getThemeName(state) {
            return state.themeName
        }
    },
    // 2.3actions
    actions: {
        // 修改主题名称
        changeThemeName() {
            this.themeName = this.themeName == "dark" ? 'vintage' : "dark"
            this.autoTheme = changeAutoTheme(this.themeName)
        }
    }
})